package cn.briarbear.myblog.security;

import cn.briarbear.myblog.entity.table.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import cn.briarbear.myblog.repository.AdminRepository;

/**
 * 管理员验证验证
 *
 * @auther Val1ant
 * @blog http://www.val1ant.xin
 * @create 2018-05-11-9:49
 */
@Service
public class AdminUserService implements UserDetailsService {
    @Autowired
    private AdminRepository adminRepository;


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        Admin admin = adminRepository.findByUsername(username);
//        Set<GrantedAuthority> grantedAuthorities = new HashSet<>();


        if (admin != null)
            return admin ;

        return null;


    }


}
